#include <iostream>
#include <stdio.h>
#include <pthread.h>  
using namespace std;  
#define NUM_THREADS 5  
void* say_hello(void* args)  
{  
	//int i = *((int*)args);
	printf("hello in %d\n", *((int*)args));
}  

int main()  
{  
	pthread_t tids[NUM_THREADS];  
	cout << "hello in main..." << endl;  
	for(int i = 0; i < NUM_THREADS; ++i)  
	{  
		int ret = pthread_create(&tids[i], NULL, say_hello, (void *)&i);
		cout << "Current pthread id =" << tids[i] << endl;
		if (ret != 0)  
		{  
			cout << "pthread_create error: error_code=" << ret << endl;  
		}  
	}  
	pthread_exit(NULL);  
}  
